package cn.kgc.springboot.controller;

import cn.kgc.springboot.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;

/**
 * @author mosin
 * date 2021/12/13
 * @version 1.0
 */
@Controller
@RequestMapping("thymeleaf")
public class ThymeleafController {

    @RequestMapping("/t1")
    public  String helloThymeleaf(Model model, HttpSession session){
        model.addAttribute("msg", "<a href='http://wwww.baidu.com'>world</a>");
        model.addAttribute("number", 10);
        Student student = new Student();
        student.setStuName("lisi");
        student.setAge(20);
        student.setBirth(new Date());
        model.addAttribute("student", student);
        ArrayList<Student> students = new ArrayList<>();
        students.add(student);
        students.add(student);
        students.add(student);
        model.addAttribute("students", students);

        session.setAttribute("number2", 20);

        return "hello";
    }

}
